package gbench.mydata.driver.core.data;

import gbench.common.fs.XlsFile.SimpleExcel;
import gbench.common.fs.XlsFile.StrMatrix;

/**
 * 数据文件
 * 
 * @author gbench
 *
 */
public class DataFile implements IDataFile  {

    /**
     * 构造函数
     * 
     * @param filename
     */
    public DataFile(final String filename) {
        this.filename = filename;
        excel = new SimpleExcel(filename);
    }

    /**
     * 返回数据列表
     * 
     * @param sheetName 表单名称
     * @return StrMatrix
     */
    public StrMatrix get(final String sheetName) {
        return excel.autoDetect(sheetName);
    }

    /**
     * 
     * @param shtid 表单的索引id 从0开始
     * @return StrMatrix
     */
    public StrMatrix get(final Number shtid) {
        if (shtid == null) {
            return null;
        }
        return excel.autoDetect(shtid.intValue());
    }

    /**
     * 文件关闭
     */
    public void close() {
        this.excel.close();
    }

    final String filename;
    final SimpleExcel excel;
}
